Skip to content

Conversation

@aryamohanan
Copy link
Contributor

This PR fixes a compatibility issue when running Pino on Node.js 18.x versions earlier than 18.19, where diagnostics_channel.tracingChannel is not available.

Problem

In Node 18.18 and earlier, diagChannel.tracingChannel does not exist. This caused Pino’s asJson tracing logic to throw an error at runtime.

Solution

  • Added feature detection for diagChannel.tracingChannel.

  • When unavailable, provide a minimal no-op fallback:

    • hasSubscribers: false
    • traceSync() simply calls the provided function
  • Ensures asJson works normally, even without tracing support.

Notes

  • Added inline comments to clarify that tracingChannel is available starting with Node 18.19+.
  • Kept the fallback implementation minimal to avoid performance impact.

Reference

This issue was added in the latest Pino release, #2281 and diagnostics_channel.tracingChannel was introduced in Node.js starting from v18.19 (see Node.js docs).

closes #2289

@aryamohanan aryamohanan changed the title fix: provide fallback for diagChannel.tracingChannel in older node versions fix: gracefully handle missing diagChannel.tracingChannel on Node < 18.19 Sep 19, 2025
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add Node 18.18 to CI.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina
Copy link
Member

cc @jsumners

@aryamohanan
Copy link
Contributor Author

@mcollina I tested this on macOS with Node.js v20, and it passed. Could this be a flaky test in CI? Would it be possible to rerun the test?

Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not going to block this fair solution. But my opinion is that it is just adding stuff to remove for the next major (which is long overdue and something I hope to get done soon). I think we are clear that we only support the most current release in each release line, and v18.19 wasn't even the most current v18 (there were two releases of .19 and 9 releases of v18.20).

@mcollina mcollina merged commit 991a5f9 into pinojs:main Sep 20, 2025
37 of 41 checks passed
alanplatt added a commit to DEFRA/grants-ui that referenced this pull request Nov 7, 2025
![snyk-top-banner](https://res.cloudinary.com/snyk/image/upload/r-d/scm-platform/snyk-pull-requests/pr-banner-default.svg)


<h3>Snyk has created this PR to upgrade pino from 9.9.5 to 9.11.0.</h3>

:information_source: Keep your dependencies up-to-date. This makes it
easier to fix existing vulnerabilities and to more quickly identify and
fix newly disclosed vulnerabilities when they affect your project.

<hr/>


- The recommended version is **2 versions** ahead of your current
version.

- The recommended version was released **24 days ago**.




<details>
<summary><b>Release notes</b></summary>
<br/>
  <details>
    <summary>Package name: <b>pino</b></summary>
    <ul>
      <li>
<b>9.11.0</b> - <a
href="https://redirect.github.com/pinojs/pino/releases/tag/v9.11.0">2025-09-20</a></br><h2>What's
Changed</h2>
<ul>
<li>feat: added timestamp rfc3339 format with nanoseconds by <a
class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/edge33/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/edge33">@ edge33</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="3288586845" data-permission-text="Title is private"
data-url="pinojs/pino#2251"
data-hovercard-type="pull_request"
data-hovercard-url="/pinojs/pino/pull/2251/hovercard"
href="https://redirect.github.com/pinojs/pino/pull/2251">#2251</a></li>
<li>fix: gracefully handle missing diagChannel.tracingChannel on Node
&lt; 18.19 by <a class="user-mention notranslate"
data-hovercard-type="user"
data-hovercard-url="/users/aryamohanan/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/aryamohanan">@ aryamohanan</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="3433786084" data-permission-text="Title is private"
data-url="pinojs/pino#2290"
data-hovercard-type="pull_request"
data-hovercard-url="/pinojs/pino/pull/2290/hovercard"
href="https://redirect.github.com/pinojs/pino/pull/2290">#2290</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/edge33/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/edge33">@ edge33</a> made their first
contribution in <a class="issue-link js-issue-link"
data-error-text="Failed to load title" data-id="3288586845"
data-permission-text="Title is private"
data-url="pinojs/pino#2251"
data-hovercard-type="pull_request"
data-hovercard-url="/pinojs/pino/pull/2251/hovercard"
href="https://redirect.github.com/pinojs/pino/pull/2251">#2251</a></li>
<li><a class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/aryamohanan/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/aryamohanan">@ aryamohanan</a> made
their first contribution in <a class="issue-link js-issue-link"
data-error-text="Failed to load title" data-id="3433786084"
data-permission-text="Title is private"
data-url="pinojs/pino#2290"
data-hovercard-type="pull_request"
data-hovercard-url="/pinojs/pino/pull/2290/hovercard"
href="https://redirect.github.com/pinojs/pino/pull/2290">#2290</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a class="commit-link"
href="https://redirect.github.com/pinojs/pino/compare/v9.10.0...v9.11.0"><tt>v9.10.0...v9.11.0</tt></a></p>
      </li>
      <li>
<b>9.10.0</b> - <a
href="https://redirect.github.com/pinojs/pino/releases/tag/v9.10.0">2025-09-17</a></br><h2>What's
Changed</h2>
<ul>
<li>docs: Move pino-logflare out of legacy transports list by <a
class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/kamilogorek/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/kamilogorek">@ kamilogorek</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="3406229630" data-permission-text="Title is private"
data-url="pinojs/pino#2283"
data-hovercard-type="pull_request"
data-hovercard-url="/pinojs/pino/pull/2283/hovercard"
href="https://redirect.github.com/pinojs/pino/pull/2283">#2283</a></li>
<li>Add support for <code>Pear</code> and <code>Bare</code> runtimes by
<a class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/yassernasc/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/yassernasc">@ yassernasc</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="3388452783" data-permission-text="Title is private"
data-url="pinojs/pino#2278"
data-hovercard-type="pull_request"
data-hovercard-url="/pinojs/pino/pull/2278/hovercard"
href="https://redirect.github.com/pinojs/pino/pull/2278">#2278</a></li>
<li>Add tracing channels by <a class="user-mention notranslate"
data-hovercard-type="user"
data-hovercard-url="/users/jsumners-nr/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/jsumners-nr">@ jsumners-nr</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="3402802217" data-permission-text="Title is private"
data-url="pinojs/pino#2281"
data-hovercard-type="pull_request"
data-hovercard-url="/pinojs/pino/pull/2281/hovercard"
href="https://redirect.github.com/pinojs/pino/pull/2281">#2281</a></li>
<li>Add pino-console to ecoystem page by <a class="user-mention
notranslate" data-hovercard-type="user"
data-hovercard-url="/users/mcollina/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/mcollina">@ mcollina</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="3426535226" data-permission-text="Title is private"
data-url="pinojs/pino#2288"
data-hovercard-type="pull_request"
data-hovercard-url="/pinojs/pino/pull/2288/hovercard"
href="https://redirect.github.com/pinojs/pino/pull/2288">#2288</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/kamilogorek/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/kamilogorek">@ kamilogorek</a> made
their first contribution in <a class="issue-link js-issue-link"
data-error-text="Failed to load title" data-id="3406229630"
data-permission-text="Title is private"
data-url="pinojs/pino#2283"
data-hovercard-type="pull_request"
data-hovercard-url="/pinojs/pino/pull/2283/hovercard"
href="https://redirect.github.com/pinojs/pino/pull/2283">#2283</a></li>
<li><a class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/yassernasc/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/yassernasc">@ yassernasc</a> made
their first contribution in <a class="issue-link js-issue-link"
data-error-text="Failed to load title" data-id="3388452783"
data-permission-text="Title is private"
data-url="pinojs/pino#2278"
data-hovercard-type="pull_request"
data-hovercard-url="/pinojs/pino/pull/2278/hovercard"
href="https://redirect.github.com/pinojs/pino/pull/2278">#2278</a></li>
<li><a class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/jsumners-nr/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/jsumners-nr">@ jsumners-nr</a> made
their first contribution in <a class="issue-link js-issue-link"
data-error-text="Failed to load title" data-id="3402802217"
data-permission-text="Title is private"
data-url="pinojs/pino#2281"
data-hovercard-type="pull_request"
data-hovercard-url="/pinojs/pino/pull/2281/hovercard"
href="https://redirect.github.com/pinojs/pino/pull/2281">#2281</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a class="commit-link"
href="https://redirect.github.com/pinojs/pino/compare/v9.9.5...v9.10.0"><tt>v9.9.5...v9.10.0</tt></a></p>
      </li>
      <li>
<b>9.9.5</b> - <a
href="https://redirect.github.com/pinojs/pino/releases/tag/v9.9.5">2025-09-10</a></br><h2>What's
Changed</h2>
<ul>
<li>fix: allow object type in %s placeholder by <a class="user-mention
notranslate" data-hovercard-type="user"
data-hovercard-url="/users/mcollina/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/mcollina">@ mcollina</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="3388093159" data-permission-text="Title is private"
data-url="pinojs/pino#2277"
data-hovercard-type="pull_request"
data-hovercard-url="/pinojs/pino/pull/2277/hovercard"
href="https://redirect.github.com/pinojs/pino/pull/2277">#2277</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a class="commit-link"
href="https://redirect.github.com/pinojs/pino/compare/v9.9.4...v9.9.5"><tt>v9.9.4...v9.9.5</tt></a></p>
      </li>
    </ul>
from <a href="https://redirect.github.com/pinojs/pino/releases">pino
GitHub release notes</a>
  </details>
</details>

---

> [!IMPORTANT]
>
> - Check the changes in this PR to ensure they won't cause issues with
your project.
> - This PR was automatically created by Snyk using the credentials of a
real user.

---

**Note:** _You are seeing this because you or someone else with access
to this repository has authorized Snyk to open upgrade PRs._

**For more information:** <img
src="https://api.segment.io/v1/pixel/track?data=eyJ3cml0ZUtleSI6InJyWmxZcEdHY2RyTHZsb0lYd0dUcVg4WkFRTnNCOUEwIiwiYW5vbnltb3VzSWQiOiJlMGNmZDdhOS0yNzM2LTQ3ZDUtOTY5Ny1iYWZjYzg0MDk5ZDgiLCJldmVudCI6IlBSIHZpZXdlZCIsInByb3BlcnRpZXMiOnsicHJJZCI6ImUwY2ZkN2E5LTI3MzYtNDdkNS05Njk3LWJhZmNjODQwOTlkOCJ9fQ=="
width="0" height="0"/>

> - 🧐 [View latest project
report](https://app.snyk.io/org/bugbaredrums/project/cf9c5b42-a7d0-446f-a41c-275c56edf456?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr)
> - 📜 [Customise PR
templates](https://docs.snyk.io/scan-using-snyk/pull-requests/snyk-fix-pull-or-merge-requests/customize-pr-templates?utm_source=&utm_content=fix-pr-template)
> - 🛠 [Adjust upgrade PR
settings](https://app.snyk.io/org/bugbaredrums/project/cf9c5b42-a7d0-446f-a41c-275c56edf456/settings/integration?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr)
> - 🔕 [Ignore this dependency or unsubscribe from future upgrade
PRs](https://app.snyk.io/org/bugbaredrums/project/cf9c5b42-a7d0-446f-a41c-275c56edf456/settings/integration?pkg&#x3D;pino&amp;utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr#auto-dep-upgrades)

[//]: #
'snyk:metadata:{"breakingChangeRiskLevel":null,"FF_showPullRequestBreakingChanges":null,"FF_showPullRequestBreakingChangesWebSearch":null,"customTemplate":{"variablesUsed":[],"fieldsUsed":[]},"dependencies":[{"name":"pino","from":"9.9.5","to":"9.11.0"}],"env":"prod","hasFixes":false,"isBreakingChange":false,"isMajorUpgrade":false,"issuesToFix":[],"prId":"e0cfd7a9-2736-47d5-9697-bafcc84099d8","prPublicId":"e0cfd7a9-2736-47d5-9697-bafcc84099d8","packageManager":"npm","priorityScoreList":[],"projectPublicId":"cf9c5b42-a7d0-446f-a41c-275c56edf456","projectUrl":"https://app.snyk.io/org/bugbaredrums/project/cf9c5b42-a7d0-446f-a41c-275c56edf456?utm_source=github&utm_medium=referral&page=upgrade-pr","prType":"upgrade","templateFieldSources":{"branchName":"default","commitMessage":"default","description":"default","title":"default"},"templateVariants":[],"type":"auto","upgrade":[],"upgradeInfo":{"versionsDiff":2,"publishedDate":"2025-09-20T13:03:07.987Z"},"vulns":[]}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[email protected] breaks on Node v18.18 due to missing diagnostics_channel.tracingChannel

3 participants